package com.mylib.libcore.network.interceptor;

import android.util.Log;

import androidx.annotation.NonNull;

import com.mylib.libcore.AppContext;
import com.mylib.libcore.utils.UIUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * 添加公共头信息
 */
public class CommonHeaderInterceptor implements Interceptor {

    public CommonHeaderInterceptor() {
    }

    @Override
    public Response intercept(@NonNull Chain chain) throws IOException {
        //统一设置请求头
        Request original = chain.request();

        Request.Builder requestBuilder = original.newBuilder();


        requestBuilder.addHeader("wdt", AppContext.getInstance().getAppPreferencesHelper().getToken());
        requestBuilder.addHeader("dt", "android");

        requestBuilder.method(original.method(), original.body());

        Request request = requestBuilder.build();
        return chain.proceed(request);
    }
}
